import { defineStore } from "pinia";
import defaultSettings from "@/settings";
import { store } from '@/store';

// 导入 Element Plus 中英文语言包
import zhCn from "element-plus/es/locale/lang/zh-cn";
import en from "element-plus/es/locale/lang/en";

// setup
export const useAppStore = defineStore("app", () => {
  // state
  const language = useStorage("language", defaultSettings.language);

  const locale = computed(() => {
    if (language?.value == "en") {
      return en;
    } else {
      return zhCn;
    }
  });

  const size = useStorage("size", defaultSettings.size);

  return {
    language,
    locale,
    size
  };
});

export function useAppStoreHook() {
  return useAppStore(store);
}
